package com.ydc.ln.tutorial.j2se.ms;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;

public class Ch1005 {

    public static void main(String[] args) {
        int[] a = {1, 2, 3, 4, 5};
        int[] b = {3, 4, 5, 6, 7};
        
        new Ch1005().test001(a, b);
        
        Map<String, Object> map = new HashMap<String, Object>();
        map = new Hashtable<String, Object>();
    }

    public void test002 (String[] a, String[] b) {
        
    }
    
    public void test001(int[] a, int[] b) {
        int aLen = a.length;
        int bLen = b.length;
        int minLen = aLen < bLen ? aLen : bLen;
        int[] c = new int[minLen];
        int i = 0;
        int j = 0;
        int k = 0;
        while (i < aLen && j < bLen) {
            if (a[i] == b[j]) {
                c[k++] = a[i];
                i++;
                j++;
            } else if (a[i] < b[j]) {
                i++;
            } else if (a[i] > b[j]) {
                j++;
            }
        }

        for (int tmp : c) {
            System.out.print(tmp + "\t");
        }

    }
}


abstract class Test001 {

}
